/*
 * @Author: szx
 * @Date: 2021-10-28 20:14:13
 * @LastEditTime: 2021-10-28 20:25:00
 * @Description:
 * @FilePath: \leetcode\1\1.cpp
 */
#include <iostream>
#include <unordered_map>
#include <vector>
using namespace std;

class Solution {
   public:
    vector<int> twoSum(vector<int>& nums, int target) {
        unordered_map<int, int> m;
        for (int i = 0; i < nums.size(); i++) {
            auto it = m.find(target - nums[i]);
            if (it != m.end()) {
                return {it->second, i};
            }
            m[nums[i]] = i;
        }
        return {};
    }
};
int main() {
    vector<int> v = {3, 2, 4};
    Solution s;
    vector<int> res = s.twoSum(v, 6);
    for (int& i : res) {
        cout << i << " ";
    }
    return 0;
}